package com.sky.controller.User;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController("userShopController")
@RequestMapping("/user/shop")
@Api
public class ShopController {
    private static final String SHOPSTATUS = "shop_status";
    @Autowired
    public RedisTemplate redisTemplate;

    @ApiOperation("在手机端获得店铺的营业状态")
    @GetMapping("/status")
    public Result<Integer> getStatus(){
       Integer status = (Integer) redisTemplate.opsForValue().get(SHOPSTATUS);
       log.info("查询到的店铺的营业状态为:{}",status==1? "营业":"打烊");
        return Result.success(status);
    }
}
